﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Windows.Forms;
using unitlControl;
using QLTH_BUSINESS;
using QLTH_DTO;

namespace QuanLy_THPT_S4
{
    public partial class frmMonHoc : Form
    {
        private readonly clsMonHocBU _mhBU;
        private readonly clsMonHocDTO _mhDTO;
        private readonly clsTCMBU _tcmBU;
        public frmMonHoc()
        {
            InitializeComponent();
            _mhBU = new clsMonHocBU();
            _mhDTO = new clsMonHocDTO();
            _tcmBU = new clsTCMBU();
        }

        private void panelControl5_Paint(object sender, PaintEventArgs e)
        {

        }

        private void frmMonHoc_Load(object sender, EventArgs e)
        {
            ComboUtils.SetDataSuorce(cmbTCM, _tcmBU.DanhSachTCM(), "MATCM", "TOCHUYENMON", 0);
            spinSOTIET.Properties.MaxValue = 50;
            spinSOTIET.Properties.MinValue = 0;
            spinHESO.Properties.MaxValue = 5;
            spinHESO.Properties.MinValue = 1;
        }

        private void btnThemMon_Click(object sender, EventArgs e)
        {
            if (txtMonHoc == null)
            {
                MessageboxUtils.Error("Tên môn học trống");
            }
            else
            {
                _mhDTO.Mamh = toancuc.Tao_ma(_mhBU.macuoi(), "MH", 2);
                _mhDTO.Tenmh = txtMonHoc.Text;
                _mhDTO.Heso = int.Parse(spinHESO.EditValue.ToString());
                _mhDTO.Sotiet = int.Parse(spinSOTIET.EditValue.ToString());
                _mhDTO.Tcm.Tentcm = ComboUtils.LayGT_Combobox(cmbTCM);
                _mhBU.ThemMonHoc(_mhDTO);

            }
        }
    }
}
